// 蜂窝蜜造平台生成代码，如手工更改，请添加到 .beeignore 忽略生成

package com.fowo.api.inventory.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.fowo.api.inventory.entity.Inventory;
import com.fowo.api.inventory.model.*;

import java.util.Date;
import java.util.List;

import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

@Mapper
public interface InventoryMapper extends BaseMapper<Inventory> {
    Page<InventoryItemVo> pageSearch(
            @Param("page") Page page,
            @Param("search") InventorySearchParamPo search
    );

    List<InventoryItemVo> search(@Param("search") InventorySearchParamPo search);

    Date searchLastUpdateTime(@Param("search") InventorySearchParamPo search);

    /**
     * 搜索满足条件的所有记录的编号列表
     *
     * @param search 搜索参数
     * @return 编号列表
     */
    List<Long> searchIds(@Param("search") InventorySearchParamPo search);

    Long getIdByStockId(@Param("stockId") Integer stockId);

    List<Long> getIdsByStockId(@Param("list") List<Integer> list);

    Integer getStockIdById(@Param("id") Long id);

    List<Integer> getStockIdByIds(@Param("ids") List<Long> ids);

    InventoryVo selectVoById(@Param("id") Long id);

    /**
     * 入库查询
     *
     * @param inventoryStorageVo
     * @return
     */

    List<Inventory> selectByStorageOne(@Param("search") InventoryStorageVo inventoryStorageVo);

    /**
     * 自定义查询物品sql 展示
     *
     * @param sql
     * @return
     */
    @Select("${sql}")
    String selectMaterial(String sql);

    List<Inventory> selectByOutboundOne(@Param("search") InventoryOutboundVo inventoryOutboundVo, @Param("descOrAsc") String descOrAsc);

    List<Inventory> selectByOutboundList(@Param("search") InventoryOutboundVo inventoryOutboundVo, @Param("model") String model);

    /**
     * 自定义是否开启负库存 数量 如果 有数据>0  开启
     *
     * @param sql
     * @return
     */
    @Select("${sql}")
    Integer selectNegativeInventoryCount(String sql);

    @Select("${sql}")
    Date selectCarryDate(String sql);

    List<Inventory> selectByStorageList(@Param("items") List<Long> items);

    int updateBatch(@Param("list") List<Inventory> updateInventoryList);
}
